//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
   musicList:[],
   type:[1,2,11,12,16,21,22,23,24,25]
  },

  //toList点击事件
  toList: function(event){
    wx.navigateTo({
      url: '../list/list?name='+event.currentTarget.dataset.name
    })
    console.log(event);
    
  },
  //事件处理函数
  bindViewTap: function() {
    
  },
  onLoad: function () {
    var that = this;
    //请求数据
    for(var i = 0; i< that.data.type.length; i++){
      wx.request({
        url: 'http://www.wwtliu.com/sxtstu/music/baidu/list.php?type='+that.data.type[i]+'&count=20&offset=0',
        success: function (res) {
          // console.log(res);
          that.setData({
            musicList: that.data.musicList.concat(res.data)
          },function(){
            // console.log(that.data);
          })
        }
      })
    }
  }
})
